import request from "@/utils/request.js";
import wechat from "@/libs/wechat.js";


// 配置
export function getconfig() {
	return request.get("config",{},{noAuth: true});
}

/**
 * 小程序用户登录
 * @param data object 小程序用户登陆信息
 */
export function login(data) {
	return request.post("auth/mp",data, {
		noAuth: true
	});
}

//获得appID
export function getappid(id){
	return request.post("auth/merchant",id);
}

/**
 * 获取微信sdk配置
 * @returns {*}
 */
export function getWechatConfig() {
	return request.get(
		"wechat/config",{
			url: wechat.signLink(),
			mer_id:uni.getStorageSync("mer_id")
		}, {
			noAuth: true
		}
	);
}

/**
 * 获取微信sdk配置
 * @returns {*}
 */
export function wechatAuth(code, spread, login_type, mer_id) {
	return request.get(
		"auth/wechat", {
			code: code,
			spread: spread,
			login_type: login_type,
			mer_id: mer_id
		}, {
			noAuth: true
		}
	);
}
